<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="text" value="0">
    <input type="button" id="add" value="+1">
    <input type="button" id="sub" value="-1">
</body>
<script>
    let text = document.querySelector('#text');
    let add = document.querySelector('#add');
    let sub = document.querySelector('#sub');
    add.onclick = function () {
        let num = +text.value;
        console.log(num);
        num++;
        text.value = num;
    }
    sub.onclick = function () {
        let num = +text.value;
        console.log(num);
        num--;
        text.value = num;
    }

</script>

</html>